package com.whw.fy.controller;

import com.whw.fy.entity.ClazzType;
import com.whw.fy.entity.Message;
import com.whw.fy.service.ClazzTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "课程类型模块")
@RestController
@RequestMapping("/api/clazzType")
public class ClazzTypeController {
    @Resource
    private ClazzTypeService clazzTypeService;

    @ApiOperation(value = "添加课程类型")
    @PostMapping("/one")
    public Message insert(ClazzType clazzType) {
        return clazzTypeService.insertSelective(clazzType);
    }

    @ApiOperation(value = "删除课程类型")
    @DeleteMapping("/")
    public Message delete(Integer clazzTypeId) {
        return clazzTypeService.deleteByPrimaryKey(clazzTypeId);
    }

    @ApiOperation(value = "修改课程类型")
    @PutMapping("/")
    public Message update(ClazzType clazzType) {
        return clazzTypeService.updateByPrimaryKeySelective(clazzType);
    }

    @ApiOperation(value = "获取课程类型")
    @GetMapping("/one")
    public Message selectByPrimaryKey(Integer clazzTypeId){
        return clazzTypeService.selectByPrimaryKey(clazzTypeId);
    }

    @ApiOperation(value = "根据课程类型id获得课程类型名称")
    @GetMapping("/selectName")
    public Message selectClassNameByClazzTypeId(Integer clazzTypeId){
        return clazzTypeService.selectClassNameByClazzTypeId(clazzTypeId);
    }

    @ApiOperation(value = "查询所有课程类型")
    @GetMapping("/all")
    public Message selectAll(){
        return clazzTypeService.selectAll();
    }

}
